package DataBases;

import java.util.Iterator;
import java.util.Vector;

public class VectorTreatment extends Vector<WaterTreatmentObject>{

	public WaterTreatmentObject treatment(float litres, Propiedades p){
		//System.out.println("Treatment propiedades: P: "+ p.getPhysical() +" B: "+p.getBiological()+" C: "+p.getChemical());
		//this.print();
		
		Iterator<WaterTreatmentObject> itr = this.iterator();
		while (itr.hasNext()) {
			WaterTreatmentObject w = (WaterTreatmentObject) itr.next();
			if(p.equals(w.getPropiedades())){
				//System.out.println("Treatment: Pre: "+w.getPretreatment()+" Pri: "+w.getPrimary()+" Aer: "+w.getAeration()+" Sec: "+w.getSecondary());
				WaterTreatmentObject wto = new WaterTreatmentObject(p, 
																	(int) (w.getPretreatment()*litres), 
																	(int) (w.getPrimary()*litres), 
																	(int) (w.getAeration()*litres), 
																	(int) (w.getSecondary()*litres));
				
				//System.out.println("Treatment * Litros: Pre: "+wto.getPretreatment()+" Pri: "+wto.getPrimary()+" Aer: "+wto.getAeration()+" Sec: "+wto.getSecondary());
				return wto;
			}
		}
		return null;
	}
	
	public void print(){
		Iterator<WaterTreatmentObject> itr = this.iterator();
		while (itr.hasNext()) {
			WaterTreatmentObject w = (WaterTreatmentObject) itr.next();
			System.out.println("vector: P: " +w.getPropiedades().getPhysical()+" B: "+w.getPropiedades().getBiological()+" C: "+w.getPropiedades().getChemical()+" Pre: "+w.getPretreatment()+" Pri: "+w.getPrimary()+" Aer: "+w.getAeration()+" Sec: "+w.getSecondary());		
		}		
	}
}
